﻿// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// This file is part of CodingEditor.
// Note:	This project is derived from Peter Project
//			(hosted on sourceforge and codeplex)
//
// Copyright (c) 2008-2009, CE Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


namespace CE.Splash
{
	using System;
    using System.Windows.Forms;

	public partial class SplashForm : Form, ISplashForm
	{
		#region Fields

		private float _Opacity = 0.5f;

		#endregion Fields

		#region Constructors

		public SplashForm(string version)
		{
			InitializeComponent();
			BackgroundImage = System.Drawing.Image.FromFile(CE.Classes.Constants.SplashImage);
			versionLabel.Text += version;
			SetStyle(ControlStyles.SupportsTransparentBackColor |
			         ControlStyles.AllPaintingInWmPaint |
			         ControlStyles.UserPaint |
			         ControlStyles.DoubleBuffer,
			         true);
			Opacity = 0.5;
			ShowIcon = false;
		}

		#endregion Constructors

		#region Methods

		void ISplashForm.SetStatusInfo(string NewStatusInfo)
		{
		}

		public void timer1_Tick(object sender, EventArgs e)
		{
			if (_Opacity < 1) _Opacity += 0.03f;
			Opacity = _Opacity;
			Invalidate();
		}

		private void SplashScreen_FormClosing(object sender, FormClosingEventArgs e)
		{
			this.BackgroundImage.Dispose();
			this.Dispose(true);
		}

		#endregion Methods
	}
}